﻿using System.ComponentModel;
using JetBrains.Annotations;

namespace ZOIL.DataModel
{
    /// <summary>
    /// A base class that implements the PropertyChanged event
    /// </summary>
    public class BasePropertyChange : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanging;

        [NotifyPropertyChangedInvocator]
        public void RaisePropertyChanging(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanging;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        [NotifyPropertyChangedInvocator]
        public void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion
    }
}